Component({
    properties: {
        start: {
            type: String
        },
        end: {
            type: String
        }
    },
    data: {
        showModal: false,
        animationData: null,
        isMask: true
    },
    ready() {
        this.showModal()
    },
    methods: {
        showModal() {
            const animation = wx.createAnimation({
                duration: 300,
                timingFunction: 'ease-in-out'
            })
            this.animation = animation
            animation.translateY('100%').step()
            this.setData({
                showModal: true,
                animationData: animation.export()
            })
            setTimeout(() => {
                animation.translateY(0).step()
                this.setData({
                    animationData: animation.export()
                })
            }, 50)
        },
        hideModal(e) {
            if (e.currentTarget.dataset.ok) {
                this.triggerEvent('sure')
                if (this.properties.start != '起始时间' && this.properties.end != '结束时间') {
                    const animation = wx.createAnimation({
                        duration: 300,
                        timingFunction: 'ease-out'
                    })
                    this.animation = animation
                    animation.translateY('100%').step()
                    this.setData({
                        animationData: animation.export()
                    })
                    setTimeout(() => {
                        this.setData({
                            showModal: false,
                            isMask: false
                        })
                        this.triggerEvent('cancel')
                    }, 300)
                }
            } else {
                const animation = wx.createAnimation({
                    duration: 300,
                    timingFunction: 'ease-out'
                })
                this.animation = animation
                animation.translateY('100%').step()
                this.setData({
                    animationData: animation.export()
                })
                setTimeout(() => {
                    this.setData({
                        showModal: false,
                        isMask: false
                    })
                    this.triggerEvent('cancel')
                }, 300)
            }
        },
        preventDefault() {

        }
    }
})